package com.blood.modules.pregnancy.controller;

import com.blood.core.resp.ResponseResult;
import com.blood.modules.pregnancy.dto.req.PregnancyRuleReq;
import com.blood.modules.pregnancy.dto.req.PregnancyRuleSaveReq;
import com.blood.modules.pregnancy.dto.resp.PregnancyRuleListResp;
import com.blood.modules.pregnancy.service.IPregnancyRuleService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 孕产规则Controller
 *
 * @author daoren
 * @date 2022-11-24 13:39:22
 */
@Api(value = "规则管理", tags = "规则管理")
@ApiSort(903)
@RestController
@RequestMapping("/pregnancy/rule")
public class PregnancyRuleController {

    /**
     * 孕产规则服务.
     */
    @Autowired
    private IPregnancyRuleService pregnancyRuleService;


    /**
     * 列表查询.
     *
     * @param req 请求参数
     * @return 列表信息
     */
    @ApiOperation(value = "列表查询")
    @PostMapping(value = "/List")
    public ResponseResult<PregnancyRuleListResp> getListInfo(@RequestBody PregnancyRuleReq req) {
        return pregnancyRuleService.queryListInfo(req);
    }


    /**
     * 修改.
     *
     * @param req 修改参数
     * @return 修改结果
     */
    @ApiOperation(value = "启用/禁用")
    @PostMapping(value = "/update")
    public ResponseResult<Void> update(@RequestBody @Validated PregnancyRuleSaveReq req) {
        return pregnancyRuleService.updateInfo(req);
    }
}
